package com.aiyige.page.interest.selectchannel.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.interest.model.Interest;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class AlternativeAdapter extends BaseQuickAdapter<Interest, AlternativeAdapter.VH> {
    public AlternativeAdapter() {
        super(R.layout.alternative_adapter_interest_item, new LinkedList<Interest>());
    }

    @Override
    protected void convert(AlternativeAdapter.VH helper, Interest item) {
        helper.bindData(item);
    }


    public class VH extends BaseViewHolder {
        @BindView(R.id.titleTv)
        TextView titleTv;
        @BindView(R.id.selectedIv)
        ImageView selectedIv;
        Interest data;

        public VH(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void bindData(Interest interest) {
            data = interest;
            titleTv.setText(data.getTitle());
            if (data.isSelected()) {
                selectedIv.setVisibility(View.VISIBLE);
            } else {
                selectedIv.setVisibility(View.INVISIBLE);
            }
        }
    }
}
